import { ADD_TODO, SET_USER, SET_CODE, SET_GAME_INFO, SET_LUCKY_DRAW, SET_EXCHANGE, GO_SHERD } from '../actions/actions'

export function todos(state = [], action) {
    switch (action.type) {
        case ADD_TODO:
            return [
                ...state,
                {
                    text: action.text,
                    completed: false
                }
            ]
        default:
            return state
    }
}

export function user(state = {}, action) {
    switch (action.type) {
        case SET_USER:
            return action.data
        default:
            return state
    }
}

export function code(state = "", action) {
    switch (action.type) {
        case SET_CODE:
            return action.data
        default:
            return state
    }
}

export function gameInfo(state = {}, action) {
    switch (action.type) {
        case SET_GAME_INFO:
            return action.data
        default:
            return state
    }
}

export function luckyDraw(state = {}, action) {
    switch (action.type) {
        case SET_LUCKY_DRAW:
            return action.data
        default:
            return state
    }
}

export function exchange(state = {}, action) {
    switch (action.type) {
        case SET_EXCHANGE:
            return action.data
        default:
            return state
    }
}

export function sherd(state = false, action) {
    switch (action.type) {
        case GO_SHERD:
            return action.data
        default:
            return state
    }
}
